<div class="title">
  <div class='content'>
    订做项
  </div>
</div>
<div class='info'>
  <div id="order_made_items" class="furnitures">
    <table cellspacing='1' cellpadding='1'>
      <tr>
        <th>型号</th>
        <th>名称</th>
        <th>材质</th>
        <th>规格</th>
        <th>件数</th>
        <th>来源</th>
        <th>动态</th>
      </tr>
      <% order_made.order_made_items.each do |item| %>
      <tr id='item_<%= item.id %>' class='order_made_item <%= cycle '','hh', :name => 'furniture_item' %>'>
        <td><%= item.furniture.furniture_style.code %></td>
        <td><%= item.furniture.furniture_style.name %></td>
        <td><%= item.furniture.material.code %>-<%= item.furniture.material.name %></td>
        <td><%= item.furniture.spec %></td>
        <td class='r'><%= item.order_made_count %></td>
        <td>
          <% if item.source.ordered? %>
          <%= link_to t(item.source), item.order,:target => :_blank, :title => "来自-预订单【#{item.order.order_no}】" %>
          <% elsif item.source.after_serviced? %>
          <%= link_to t(item.source), item.installation,:target => :_blank, :title => "来自-安装单【#{item.installation.install_no}】" %>
          <% else %>
          <%= t item.source %>
          <% end %>
        </td>
        <td><%= t item.last_feed.code %></td>
      </tr>
      <tr id='events_<%= item.id %>' class='item_events '>
        <td colspan='8'>
          <table class='events' cellspacing="1" cellpadding="1">
            <tr>
              <th></th>
              <th>描述</th>
              <th>
                <div class='recorder'>
                  登记人
                </div>
                <div id='item_<%= item.id %>_tools' class='item_tools'>
                  <% if being_edited %>
                  <div>                    
                     <%= link_to "删除",
                           destroy_order_made_item_order_made_url(item),
                           :remote => true,
                           :method => :delete,
                           :id => "destroy_item_#{item.id}"
                     %>
                     <script type="text/javascript" charset="utf-8">
                       $('#destroy_item_<%= item.id %>').bind('ajax:beforeSend', function () {
                         $('#events_<%= item.id %>').hide();
                         $('#item_<%= item.id %>').hide(1000);
                       })
                     </script>
                  </div>
                  <% end %>
                </div>
              </th>
            </tr>
            <% item.feeds.each_with_index do |feed,index| %>
            <tr>
              <td width='40px'><%= index + 1 %>.</td>
              <td class='d'>
                <%= raw feed.short_desc %><%= raw feed.remark.present? ? "<br/><b>备注：</b>#{raw(feed.remark) }" : '' %>
              </td>
              <td width='70px'>
                <%= order_made.creator.full_name %>
              </td>
            </tr>
            <% end %>
            <% if being_edited %>
            <tr class='<%= cycle '','hh', :name => 'event' %>'>
              <td colspan='6'>
                <% if item.last_feed.code.has_been_sent_to_factory? %>
                <%= link_to '入库登记',new_enter_item_order_made_url(item), :remote => true, :method => :get,:class => :next_step %>
                <% elsif item.last_feed.code.has_been_entered? %>
                <%= link_to '编辑入库记录',edit_enter_item_order_made_url(item.enter_item), :remote => true, :method => :get,:class => :next_step %>
                <%= link_to '删除入库记录',destroy_enter_item_order_made_url(item.enter_item), :remote => true, :method => :delete, :class => :next_step %>
                <% else %>
                  不支持的类型<%= item.status %>
                <% end %>
              </td>
            </tr>
          <% end %>
          </table>
        </td>
      </tr>
      <script type="text/javascript" charset="utf-8">
       $('#item_<%= item.id %>').toggle(
          function() {
            $(this).addClass('h');
            $('#events_<%= item.id %>').show('slow');
          },
          function() {
            $(this).removeClass('h');
            $('#events_<%= item.id %>').hide();
          }
        );
      </script>
      <% end %>
      <% if order_made.order_made_items.empty? %>
      <tr>
        <td class='c' colspan='8'>
          无记录
        </td>
      </tr>
      <% end %>
    </table>
  </div>
</div>
<% if @enter_item.present? %>
<script type="text/javascript" charset="utf-8">
  $(document).ready(function() {
    $('#item_<%= @enter_item.order_made_item_id %>').click();
  });
</script>
<% end %>